import { createSlice } from "@reduxjs/toolkit";
import type { PayloadAction, Slice } from '@reduxjs/toolkit'

export interface InitialState {
  open: boolean
}

const initialState: InitialState = {
    open: false
}


type Reducers = {
    changeOpen: (state:InitialState, action:PayloadAction<InitialState['open']>) => void
}
type Selectors = {}
const homeSlice: Slice<InitialState, Reducers, 'home', 'home', Selectors> = createSlice<InitialState, Reducers, 'home', Selectors, 'home'>({
  name: 'home',
  initialState,
  reducers: {
    changeOpen(state, action){
        state.open = action.payload
    }
  },
})

export const { changeOpen }: typeof homeSlice.actions = homeSlice.actions

export default homeSlice.reducer